<?php


namespace app\common\model;


use think\Model;

class NewsModel extends Model
{
    protected $name = 'news';

    public function getPageList($page = 1,$limit = 6)
    {
        $where = [
            'status' => 1,
        ];
        return $this
            ->where($where)
            ->whereNull('deletetime')
            ->order([
                'weigh' => 'asc',
            ])
            ->paginate($limit,false, ['page' => $page]);
    }

    public function getList($limit = 3)
    {
        $where = [
            'status' => 1,
            'index' => 1,
        ];
        return $this
            ->where($where)
            ->whereNull('deletetime')
            ->order([
                'weigh' => 'asc',
            ])
            ->limit($limit)
            ->select();
    }

    public function getDetail($id)
    {
        return $this->get($id);
    }
}